package com.example.helloandroid;

import com.example.helloandroid.R.color;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

	

	
	TextView tv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Log.i(this.toString(), "onCreate");
		
		tv = (TextView) this.findViewById(R.id.textView1);
		tv.setText("http://jumpin.cc");
		Drawable d = this.getResources().getDrawable(color.gold);
		tv.setBackgroundDrawable(d);

		TextView tv1 = (TextView) this.findViewById(R.id.textView2);
		DisplayMetrics dm = new DisplayMetrics();
		this.getWindowManager().getDefaultDisplay().getMetrics(dm);
		tv1.setText(dm.heightPixels + "," + dm.widthPixels);

		((Button) this.findViewById(R.id.button1))
				.setOnClickListener(new Button.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						tv.setText("Clicked....");
						setContentView(R.layout.activity_main1);

					}

				});

		((Button) this.findViewById(R.id.button2))
				.setOnClickListener(new Button.OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent();
						intent.setClass(MainActivity.this, MainActivity1.class);					
						
					    Bundle b = new Bundle();
					    b.putCharSequence("A1", "A1-Value");
					    
					    intent.putExtra("A", "A-Value");
					    intent.putExtras(b);
					    
						MainActivity.this.startActivity(intent);
						//MainActivity.this.finish();
						
					}

				});
	}
	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		Log.i(this.toString(), "onStart");
	}
	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		super.onRestart();
		
		Log.i(this.toString(), "onRestart");
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		
		Log.i(this.toString(), "onResume");
	}
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		
		Log.i(this.toString(), "onPause");
	}
	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		Log.i(this.toString(), "onStop");
	}	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		Log.i(this.toString(), "onDestroy");
	}
	
	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onRestoreInstanceState(savedInstanceState);
		
		Log.i(this.toString(), "onRestoreInstanceState");
	}

	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
